import 'package:shared_preferences/shared_preferences.dart';

class SpUtils {
  static Future<int> getYxsInt(String name, {int def = -1}) async {
    var sp = await SharedPreferences.getInstance();
    return sp.getInt(name) ?? def;
  }

  static Future<String> getYxsString(String name, {String def = ''}) async {
    var sp = await SharedPreferences.getInstance();
    return sp.getString(name) ?? def;
  }

  static Future<bool> getYxsBool(String name, {bool def = false}) async {
    var sp = await SharedPreferences.getInstance();
    return sp.getBool(name) ?? def;
  }

  static void setYxsInt(String name, int def) async {
    var sp = await SharedPreferences.getInstance();
    sp.setInt(name, def);
  }

  static void setYxsString(String name, String def) async {
    var sp = await SharedPreferences.getInstance();
    sp.setString(name, def);
  }

  static void setYxsBool(String name, bool def) async {
    var sp = await SharedPreferences.getInstance();
    sp.setBool(name, def);
  }
}
